package org.zzh.controller.system.module;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import org.zzh.dao.common.PageBean;
import org.zzh.domain.system.module.SsModule;
import org.zzh.service.system.module.SsModuleService;

/**
 * @author 十里坡
 */
@Controller
@RequestMapping("/system/module")
@Slf4j
public class SsModuleController {

    @Autowired
    private SsModuleService ssModuleService;

    @RequestMapping(value = "/list.do")
    public ModelAndView list(
            @RequestParam(required = false, value = "page", defaultValue = "1") Integer page,
            @RequestParam(required = false, value = "pageSize", defaultValue = "5") Integer pageSize,
            @RequestParam(required = false, value = "name", defaultValue = "") String name
    ) {
        PageBean<SsModule> pageBean = ssModuleService.list(page, pageSize, name);
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("pageBean", pageBean);
        modelAndView.addObject("name", name);
        modelAndView.setViewName("/WEB-INF/pages/system/module/module-list");
        return modelAndView;
    }

    @RequestMapping(value = "/toAdd.do")
    public ModelAndView toAdd() {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("/WEB-INF/pages/system/module/module-add");
        return modelAndView;
    }

}
